<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link type="text/css" rel="stylesheet" href="css/style.css"/>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!--[if IE 6]>
    <script src="js/iepng.js" type="text/javascript"></script>
    <script type="text/javascript">
        EvPNG.fix('div, ul, img, li, input, a');
    </script>
    <![endif]-->

    <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="js/menu.js"></script>

    <script type="text/javascript" src="js/select.js"></script>
    <script type="text/javascript" src="js/axios.min.js"></script>
    <script type="text/javascript" src="js/vue.min.js"></script>
    <script src="https://unpkg.com/element-ui@2.15.8/lib/index.js"></script>

    <title>尤洪</title>
</head>
<body>
<!--Begin Header Begin-->
<div id="head">
    <div class="soubg">
        <div class="sou">
            <!--Begin 所在收货地区 Begin-->
            <span class="s_city_b">
        	<span class="fl">送货至：</span>
            <span class="s_city">
            	<span>四川</span>
                <div class="s_city_bg">
                	<div class="s_city_t"></div>
                    <div class="s_city_c">
                    	<h2>请选择所在的收货地区</h2>
                        <table border="0" class="c_tab" style="width:235px; margin-top:10px;" cellspacing="0"
                               cellpadding="0">
                          <tr>
                            <th>A</th>
                            <td class="c_h"><span>安徽</span><span>澳门</span></td>
                          </tr>
                          <tr>
                            <th>B</th>
                            <td class="c_h"><span>北京</span></td>
                          </tr>
                          <tr>
                            <th>C</th>
                            <td class="c_h"><span>重庆</span></td>
                          </tr>
                          <tr>
                            <th>F</th>
                            <td class="c_h"><span>福建</span></td>
                          </tr>
                          <tr>
                            <th>G</th>
                            <td class="c_h"><span>广东</span><span>广西</span><span>贵州</span><span>甘肃</span></td>
                          </tr>
                          <tr>
                            <th>H</th>
                            <td class="c_h"><span>河北</span><span>河南</span><span>黑龙江</span><span>海南</span><span>湖北</span><span>湖南</span></td>
                          </tr>
                          <tr>
                            <th>J</th>
                            <td class="c_h"><span>江苏</span><span>吉林</span><span>江西</span></td>
                          </tr>
                          <tr>
                            <th>L</th>
                            <td class="c_h"><span>辽宁</span></td>
                          </tr>
                          <tr>
                            <th>N</th>
                            <td class="c_h"><span>内蒙古</span><span>宁夏</span></td>
                          </tr>
                          <tr>
                            <th>Q</th>
                            <td class="c_h"><span>青海</span></td>
                          </tr>
                          <tr>
                            <th>S</th>
                            <td class="c_h"><span>上海</span><span>山东</span><span>山西</span><span class="c_check">四川</span><span>陕西</span></td>
                          </tr>
                          <tr>
                            <th>T</th>
                            <td class="c_h"><span>台湾</span><span>天津</span></td>
                          </tr>
                          <tr>
                            <th>X</th>
                            <td class="c_h"><span>西藏</span><span>香港</span><span>新疆</span></td>
                          </tr>
                          <tr>
                            <th>Y</th>
                            <td class="c_h"><span>云南</span></td>
                          </tr>
                          <tr>
                            <th>Z</th>
                            <td class="c_h"><span>浙江</span></td>
                          </tr>
                        </table>
                    </div>
                </div>
            </span>
        </span>
            <!--End 所在收货地区 End-->
            <span class="fr">
        	<span class="fl" v-show="loginUser===''">你好，请<a href="Login.html">登录</a>&nbsp;
                <a href="Regist.html" style="color:#ff4e00;">免费注册</a>&nbsp;|&nbsp;
            </span>
            <span class="fl" v-show="loginUser!==''">
                 <a href="Member_Order.html">我的订单</a>&nbsp;|
                 <a href="Member_UserInfo.html">后台</a>&nbsp;|
                 <a href="JavaScript:void(0)" @click="logout">注销</a>&nbsp;|
            </span>
        	<span class="ss">
            	<div class="ss_list">
                	<a href="#">收藏夹</a>
                    <div class="ss_list_bg">
                    	<div class="s_city_t"></div>
                        <div class="ss_list_c">
                        	<ul>
                            	<li><a href="#">我的收藏夹</a></li>
                                <li><a href="#">我的收藏夹</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="ss_list">
                	<a href="#">客户服务</a>
                    <div class="ss_list_bg">
                    	<div class="s_city_t"></div>
                        <div class="ss_list_c">
                        	<ul>
                            	<li><a href="#">客户服务</a></li>
                                <li><a href="#">客户服务</a></li>
                                <li><a href="#">客户服务</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="ss_list">
                	<a href="#">网站导航</a>
                    <div class="ss_list_bg">
                    	<div class="s_city_t"></div>
                        <div class="ss_list_c">
                        	<ul>
                            	<li><a href="#">网站导航</a></li>
                                <li><a href="#">网站导航</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </span>
            <span class="fl">|&nbsp;关注我们：</span>
            <span class="s_sh"><a href="#" class="sh1">新浪</a><a href="#" class="sh2">微信</a></span>
            <span class="fr">|&nbsp;<a href="#">手机版&nbsp;<img src="images/s_tel.png" align="absmiddle"/></a></span>
        </span>
        </div>
    </div>
    <div class="top">
        <div class="logo"><a href="Index.html"><img src="images/logo.png"/></a></div>
    </div>
</div>
<!--End Header End-->
<div class="i_bg bg_color">
    <!--Begin 用户中心 Begin -->
    <div class="m_content">
        <div class="m_left">
            <div class="left_n">管理中心</div>
            <div class="left_m">
                <div class="left_m_t t_bg1">订单中心</div>
                <ul>
                    <li><a href="Member_Order.html">我的订单</a></li>
                    <li v-show="user.type===1"><a href="Member_Order.html">订单管理</a></li>
                    <li><a href="Member_Address.html">收货地址</a></li>
                </ul>
            </div>
            <div class="left_m">
                <div class="left_m_t t_bg2">用户中心</div>
                <ul>
                    <li><a href="Member_UserInfo.html">用户信息</a></li>
                    <li><a href="Member_UserPwd.html">修改密码</a></li>
                    <li v-show="user.type===1"><a href="Member_UserManage.html">用户管理</a></li>
                    <li><a href="Member_Collect.html">我的收藏</a></li>
                </ul>
            </div>
            <div class="left_m" v-show="user.type===1">
                <div class="left_m_t t_bg3">商品中心</div>
                <ul>
                    <li><a href="Member_ProManage.html">商品管理</a></li>
                    <li><a href="Member_CateManage.html">类型管理</a></li>
                </ul>
            </div>
            <div class="left_m">
                <div class="left_m_t t_bg3">资讯中心</div>
                <ul>
                    <li><a href="Member_NewsManage.html">全部咨询</a></li>
                </ul>
            </div>
        </div>
        <div class="m_right">
            <p></p>
            <div class="mem_tit">新增地址</div>
            <table border="0" class="add_tab" style="width:930px;" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="135" align="right">配送地区</td>
                    <td colspan="3" style="font-family:'宋体';">
                        <select name="county" v-model="province" v-if="province" :disabled="isdisabled[0]">
                            <option value="0">请选择...</option>
                            <option v-for="(value,key) in provinces" :value="key">{{ value }}</option>
                        </select>
                        <select name="city" v-model="city" v-if="city" :disabled="isdisabled[1]">
                            <option value="0">请选择...</option>
                            <option v-for="(value,key) in cities" :value="key">{{ value }}</option>
                        </select>
                        <select name="county" v-model="county" v-if="county" :disabled="isdisabled[2]">
                            <option value="0">请选择...</option>
                            <option v-for="(value,key) in counties" :value="key">{{ value }}</option>
                        </select>
                        <select name="town" v-model="town" v-if="town" :disabled="isdisabled[3]" v-show="isshow">
                            <option value="0">请选择...</option>
                            <option v-for="(value,key) in towns" :value="key">{{ value }}</option>
                        </select>
                        （必填）
                    </td>
                </tr>
                <tr>
                    <td width="135" align="right">详细地址</td>
                    <td colspan="3" style="font-family:'宋体';"><input type="text" style="width: 85%;"
                                                                     class="add_ipt" v-model="detailaddress"/>（必填）
                    </td>
                </tr>
                <tr>
                    <td align="right">收货人姓名</td>
                    <td style="font-family:'宋体';"><input type="text" v-model="name" @blur="checkthisName(name)"
                                                         class="add_ipt"/>（必填）
                    </td>
                    <td align="right">电子邮箱</td>
                    <td style="font-family:'宋体';"><input type="text" v-model="email" @blur="checkthisEmail(email)"
                                                         class="add_ipt"/>（必填）
                    </td>
                </tr>
                <tr>
                    <td align="right">手机号码</td>
                    <td style="font-family:'宋体';"><input type="text" v-model="mobile" @blur="checkthisMobile(mobile)"
                                                         class="add_ipt"/>（必填）
                    </td>
                    <td align="right">备注</td>
                    <td style="font-family:'宋体';"><input type="text" class="add_ipt" v-model="remark"/></td>
                </tr>
            </table>
            <p align="right">
                <a href="javascript:void(0);" @click="addAddress" class="add_b">保存地址</a>
            </p>
            <div class="mem_tit">收货地址</div>
            <table border="0" class="order_tab" v-if="userAddressesList.length>0"
                   style="width:930px; text-align:center; margin-bottom:30px;"
                   cellspacing="0" cellpadding="0">
                <tr>
                    <td width="15%">收货人</td>
                    <td width="20%">所在地区</td>
                    <td width="20%">详细地址</td>
                    <td width="10%">电子邮箱</td>
                    <td width="15%">手机号码</td>
                    <td width="10%">操作</td>
                    <td width="10%">&nbsp;</td>
                </tr>
                <tr v-for="(userAddress,index) in userAddressesList">
                    <td><font color="#ff4e00">{{userAddress.name}}</font></td>
                    <td>{{userAddress.maxAddress}}</td>
                    <td>{{userAddress.minAddress}}</td>
                    <td>{{userAddress.email}}</td>
                    <td>{{userAddress.mobile}}</td>
                    <td>
                        <a href="javascript:void(0);"
                           @click="showAddress(userAddress)">修改</a>
                        |
                        <a href="javascript:void(0);" @click="delAddress(userAddress.id,index)">删除</a>
                    </td>
                    <td>
                        <button @click="setIsDefault(userAddress.id)" v-show="!userAddress.isDefault">设为默认</button>
                        <span class="add_b" v-show="userAddress.isDefault">默认地址</span>
                    </td>
                </tr>
            </table>
            <div style="text-align: center" v-if="userAddressesList.length===0">
                暂未添加地址
            </div>


            <!--弹出层开始-->
            <el-dialog title="修改地址" :visible.sync="dialogFormVisible">
                <table border="0" class="add_tab" style="width:100%;" cellspacing="0" cellpadding="0">
                    <tr>
                        <td width="135" align="right">配送地区</td>
                        <td colspan="3" style="font-family:'宋体';">
                            <select name="county" v-model="province2" v-if="province2" :disabled="isdisabled2[0]">
                                <option value="0">请选择...</option>
                                <option v-for="(value,key) in provinces2" :value="key">{{ value }}</option>
                            </select>
                            <select name="city" v-model="city2" v-if="city2" :disabled="isdisabled2[1]">
                                <option value="0">请选择...</option>
                                <option v-for="(value,key) in cities2" :value="key">{{ value }}</option>
                            </select>
                            <select name="county" v-model="county2" v-if="county2" :disabled="isdisabled2[2]">
                                <option value="0">请选择...</option>
                                <option v-for="(value,key) in counties2" :value="key">{{ value }}</option>
                            </select>
                            <select name="town" v-model="town2" v-if="town2" :disabled="isdisabled2[3]"
                                    v-show="isshow2">
                                <option value="0">请选择...</option>
                                <option v-for="(value,key) in towns2" :value="key">{{ value }}</option>
                            </select>
                            （必填）
                        </td>
                    </tr>
                    <tr>
                        <td width="135" align="right">详细地址</td>
                        <td colspan="3" style="font-family:'宋体';"><input type="text" style="width: 85%;"
                                                                         class="add_ipt"
                                                                         v-model="userAddress.minAddress"/>（必填）
                        </td>
                    </tr>
                    <tr>
                        <td align="right">收货人姓名</td>
                        <td style="font-family:'宋体';"><input type="text" v-model="userAddress.name"
                                                             @blur="checkthisName(userAddress.name)" class="add_ipt"/>（必填）
                        </td>
                        <td align="right">电子邮箱</td>
                        <td style="font-family:'宋体';"><input type="text" v-model="userAddress.email"
                                                             @blur="checkthisEmail(userAddress.email)" class="add_ipt"/>（必填）
                        </td>
                    </tr>
                    <tr>
                        <td align="right">手机号码</td>
                        <td style="font-family:'宋体';"><input type="text" v-model="userAddress.mobile"
                                                             @blur="checkthisMobile(userAddress.mobile)"
                                                             class="add_ipt"/>（必填）
                        </td>
                        <td align="right">备注</td>
                        <td style="font-family:'宋体';"><input type="text" class="add_ipt" v-model="userAddress.remark"/>
                        </td>
                    </tr>
                </table>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogFormVisible = false">取 消</el-button>
                    <el-button type="primary" @click="editAddress()">保 存</el-button>
                </div>
            </el-dialog>
            <!--弹出层结束-->
        </div>
    </div>
</div>
<!--End 用户中心 End-->

<!--Begin Footer Begin -->
<div class="b_btm_bg b_btm_c">
    <div class="b_btm">
        <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;"
               cellspacing="0" cellpadding="0">
            <tr>
                <td width="72"><img src="images/b1.png" width="62" height="62"/></td>
                <td><h2>正品保障</h2>正品行货 放心购买</td>
            </tr>
        </table>
        <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;"
               cellspacing="0" cellpadding="0">
            <tr>
                <td width="72"><img src="images/b2.png" width="62" height="62"/></td>
                <td><h2>满38包邮</h2>满38包邮 免运费</td>
            </tr>
        </table>
        <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;"
               cellspacing="0" cellpadding="0">
            <tr>
                <td width="72"><img src="images/b3.png" width="62" height="62"/></td>
                <td><h2>天天低价</h2>天天低价 畅选无忧</td>
            </tr>
        </table>
        <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;"
               cellspacing="0" cellpadding="0">
            <tr>
                <td width="72"><img src="images/b4.png" width="62" height="62"/></td>
                <td><h2>准时送达</h2>收货时间由你做主</td>
            </tr>
        </table>
    </div>
</div>
<div class="b_nav">
    <dl>
        <dt><a href="#">新手上路</a></dt>
        <dd><a href="#">售后流程</a></dd>
        <dd><a href="#">购物流程</a></dd>
        <dd><a href="#">订购方式</a></dd>
        <dd><a href="#">隐私声明</a></dd>
        <dd><a href="#">推荐分享说明</a></dd>
    </dl>
    <dl>
        <dt><a href="#">配送与支付</a></dt>
        <dd><a href="#">货到付款区域</a></dd>
        <dd><a href="#">配送支付查询</a></dd>
        <dd><a href="#">支付方式说明</a></dd>
    </dl>
    <dl>
        <dt><a href="#">会员中心</a></dt>
        <dd><a href="#">资金管理</a></dd>
        <dd><a href="#">我的收藏</a></dd>
        <dd><a href="#">我的订单</a></dd>
    </dl>
    <dl>
        <dt><a href="#">服务保证</a></dt>
        <dd><a href="#">退换货原则</a></dd>
        <dd><a href="#">售后服务保证</a></dd>
        <dd><a href="#">产品质量保证</a></dd>
    </dl>
    <dl>
        <dt><a href="#">联系我们</a></dt>
        <dd><a href="#">网站故障报告</a></dd>
        <dd><a href="#">购物咨询</a></dd>
        <dd><a href="#">投诉与建议</a></dd>
    </dl>
    <div class="b_tel_bg">
        <a href="#" class="b_sh1">新浪微博</a>
        <a href="#" class="b_sh2">腾讯微博</a>
        <p>
            服务热线：<br/>
            <span>400-123-4567</span>
        </p>
    </div>
    <div class="b_er">
        <div class="b_er_c"><img src="images/er.gif" width="118" height="118"/></div>
        <img src="images/ss.png"/>
    </div>
</div>
<div class="btmbg">
    <div class="btm">
        备案/许可证编号：蜀ICP备12009302号-1-www.dingguagua.com Copyright © 2015-2018 尤洪商城网 All Rights Reserved. 复制必究 , Technical
        Support: Dgg Group <br/>
        <img src="images/b_1.gif" width="98" height="33"/><img src="images/b_2.gif" width="98" height="33"/><img
            src="images/b_3.gif" width="98" height="33"/><img src="images/b_4.gif" width="98" height="33"/><img
            src="images/b_5.gif" width="98" height="33"/><img src="images/b_6.gif" width="98" height="33"/>
    </div>
</div>
<!--End Footer End -->
</div>

<img src="images/b1.png" alt=""/>
<script type="text/javascript">
    new Vue({
        el: "#head",
        data: {
            loginUser: "",
            name: "",
        },
        created() {
            this.getUser();
        },
        methods: {
            getUser() {
                axios("index/getUser").then(res => {
                    this.loginUser = res.data;
                    if (this.loginUser === '') {
                        alert("用户未登录！");
                        window.location.href = "Index.html";
                    }
                })
            },
            logout() {
                axios("index/logout").then(res => {
                    this.getUser();
                    alert("退出成功！");
                })
            },
            searchByName() {
                window.location.href = "CategoryList.html?type=str&name=" + this.name;
            }
        }
    });
    var vm = {
        data() {
            return {
                dialogFormVisible: false,
                province: '0',
                provinces: {},
                city: '0',
                cities: {},
                county: '0',
                counties: {},
                town: '0',
                towns: {},
                isdisabled: [false, true, true, true],
                notowns: 1,
                isshow: 0,
                detailaddress: '',
                remark: '',
                user: {},
                userAddressesList: {},
                province2: '0',
                provinces2: {},
                city2: '0',
                cities2: {},
                county2: '0',
                counties2: {},
                town2: '0',
                towns2: {},
                isdisabled2: [false, true, true, true],
                notowns2: 1,
                isshow2: 0,
                init: 0,
                name: "",
                mobile: "",
                email: "",
                userAddress: ''
            }
        },
        created: function () {
            this.update('0000', 0);
            this.getUser();

        },
        beforeUpdate() {
            if (this.notowns == 0) {
                this.isshow = 1;
            }
            if (this.notowns2 == 0) {
                this.isshow2 = 1;
            }
        },
        methods: {
            getUser() {
                axios.get('index/getUser')
                    .then(rs => {
                        this.user = rs.data;
                        this.getUserAddressList();
                    })
            },
            isEmpty(obj) {//判断是否为空
                var regu = "^[ ]+$";
                var re = new RegExp(regu);
                if (typeof obj == "undefined" || obj == null || obj == "" || re.test(obj)) {
                    return true;
                } else {
                    return false;
                }
            },
            update(str, val) {//更新地址
                console.log('更新')
                if (str == '1') {
                    var tpath = 'json/code/' + val + '.json';
                    axios
                        .get(tpath)
                        .then(rs => {
                            this.towns = rs.data
                            console.log(this.towns);
                            this.notowns = 0;
                        }).catch(function (error) { // 请求失败处理
                        console.log(error + '异常处理，请求失败');
                    });
                } else {
                    axios
                        .get('/json/history.json')
                        .then(rs => {
                            // console.log(rs);
                            switch (str) {
                                case '0000':
                                    for (var i in rs.data) {
                                        if (i.substring(2) == '0000') {
                                            this.$set(this.provinces, i, rs.data[i]);
                                        }
                                    }
                                    console.log(this.provinces)
                                    break;
                                case '00':
                                    for (var i in rs.data) {
                                        if (i.substring(2) != '0000' && i.substring(4) == '00' && i.substring(0, 2) == val.substring(0, 2)) {
                                            this.$set(this.cities, i, rs.data[i]);
                                        }
                                    }
                                    console.log(this.cities);
                                    break;
                                case '':
                                    for (var i in rs.data) {
                                        if (i.substring(4) !== '00' && i.substring(0, 4) == val.substring(0, 4)) {
                                            this.$set(this.counties, i, rs.data[i]);
                                        }
                                    }
                                    console.log(this.counties);
                                    break;
                                default :
                                    break;
                            }

                        })
                }

            },
            addAddress() {
                if (this.userAddressesList.length >= 5) {
                    alert("只能添加5条地址，请先删除再添加！")
                    return;
                }
                if (this.province == '0' || this.city == '0' || this.county == '0' || (this.isshow != 0 && this.town == '0')) {
                    alert('配送地区不完整！');
                    return;
                }

                if (this.isEmpty(this.detailaddress)) {
                    alert('详细地址不能为空！');
                    return;
                }

                if (!this.checkthisName(this.name)) {
                    return;
                }

                if (!this.checkthisMobile(this.mobile)) {
                    return;
                }

                if (!this.checkthisEmail(this.email)) {
                    return;
                }


                alert('添加地址中。。')
                if (this.town == '0') {
                    var addressCode = this.county + '000';
                    var address = this.provinces[this.province] + this.cities[this.city] + this.counties[this.county] + '|' + this.detailaddress;
                } else {
                    var addressCode = this.town + '';
                    var address = this.provinces[this.province] + this.cities[this.city] + this.counties[this.county] + this.towns[this.town] + '|' + this.detailaddress;
                }

                axios({
                    url: 'address/addAddress',
                    method: 'post',
                    data: {
                        userId: this.user.id,
                        address: address,
                        remark: this.remark,
                        addressCode: addressCode,
                        name: this.name,
                        mobile: this.mobile,
                        email: this.email
                    }
                }).then(rs => {
                    console.log(rs.data)
                    if (rs.data === 'yes') {
                        alert('收货地址新增成功');
                        window.location.reload();
                    } else {
                        alert('收货地址添加失败')
                    }
                })

            },
            getUserAddressList() {
                axios({
                    url: 'address/show',
                    method: 'get',
                    params: {
                        userId: this.user.id
                    }
                }).then(rs => {
                    console.log("获取地址")
                    console.log(rs.data);
                    this.userAddressesList = rs.data
                    for (var i in this.userAddressesList) {
                        var arrAddress = this.userAddressesList[i].address.split("|");
                        var maxAddress = arrAddress[0];
                        var minAddress = arrAddress[1];
                        this.$set(this.userAddressesList[i], 'maxAddress', maxAddress);
                        this.$set(this.userAddressesList[i], 'minAddress', minAddress);
                    }
                })
            },
            setIsDefault(id) {
                axios({
                    url: 'address/setDefault',
                    method: 'post',
                    data: {
                        id: id,
                        userId: this.user.id,
                        isDefault: 1
                    }
                }).then(rs => {
                    if (rs.data == 'yes') {
                        alert('设置成功');
                        this.getUserAddressList();
                    } else {
                        alert('设置失败')
                    }
                })
            },
            showAddress(userAddress) {
                this.userAddress = userAddress;
                this.init = 0;
                this.update2('0000', 0);
                this.province2 = this.userAddress.addressCode.substring(0, 2) + '0000';
                this.update2('00', this.province2)
                this.city2 = this.userAddress.addressCode.substring(0, 4) + '00';
                this.update2('', this.city2);
                this.county2 = this.userAddress.addressCode.substring(0, 6);
                if (this.userAddress.addressCode.substring(6) == '000') {
                    this.town2 = '0';
                } else {
                    this.update2('1', this.county2)
                    this.town2 = this.userAddress.addressCode;
                }
                this.dialogFormVisible = true;
            },
            editAddress() {
                if (this.province2 == '0' || this.city2 == '0' || this.county2 == '0' || (this.isshow2 != 0 && this.town2 == '0')) {
                    alert('配送地区不完整！');
                    return;
                }
                if (this.isEmpty(this.userAddress.minAddress)) {
                    alert('详细地址不能为空！');
                    return;
                }
                if (!this.checkthisName(this.userAddress.name)) {
                    return;
                }
                if (!this.checkMobile(this.userAddress.mobile)) {
                    return;
                }
                if (!this.checkthisEmail(this.userAddress.email)) {
                    return;
                }
                alert('修改地址中。。')
                if (this.town2 == '0') {
                    var addressCode = this.county2 + '000';
                    var address = this.provinces2[this.province2] + this.cities2[this.city2] + this.counties2[this.county2] + '|' + this.userAddress.minAddress;
                } else {
                    var addressCode = this.town + '';
                    var address = this.provinces2[this.province2] + this.cities2[this.city2] + this.counties2[this.county2] + this.towns2[this.town2] + '|' + this.userAddress.minAddress;
                }
                axios({
                    url: 'address/editAddress',
                    method: 'post',
                    data: {
                        id: this.userAddress.id,
                        userId: this.userAddress.userId,
                        address: address,
                        remark: this.userAddress.remark,
                        addressCode: addressCode,
                        name: this.userAddress.name,
                        mobile: this.userAddress.mobile,
                        email: this.userAddress.email
                    }
                }).then(rs => {
                    if (rs.data == 'yes') {
                        alert('修改成功');
                        this.getUserAddressList();
                        this.dialogFormVisible = false
                    } else {
                        alert('修改失败')
                    }
                })

            },
            update2(str, val) {//更新地址
                console.log('更新')
                if (str == '1') {
                    var tpath = 'json/code/' + val + '.json';
                    axios
                        .get(tpath)
                        .then(rs => {
                            this.towns2 = rs.data
                            console.log(this.towns2);
                            this.notowns2 = 0;
                        });
                } else {
                    axios
                        .get('json/history.json')
                        .then(rs => {
                            switch (str) {
                                case '0000':
                                    for (var i in rs.data) {
                                        if (i.substring(2) == '0000') {
                                            this.$set(this.provinces2, i, rs.data[i]);
                                        }
                                    }
                                    console.log(this.provinces2)
                                    break;
                                case '00':
                                    for (var i in rs.data) {
                                        if (i.substring(2) != '0000' && i.substring(4) == '00' && i.substring(0, 2) == val.substring(0, 2)) {
                                            this.$set(this.cities2, i, rs.data[i]);
                                        }
                                    }
                                    break;
                                case '':
                                    for (var i in rs.data) {
                                        if (i.substring(4) !== '00' && i.substring(0, 4) == val.substring(0, 4)) {
                                            this.$set(this.counties2, i, rs.data[i]);
                                        }
                                    }
                                    console.log(this.counties2);
                                    this.init = 1;
                                    break;
                                default :
                                    break;
                            }

                        })
                }
            },
            delAddress(id, index) {
                if (confirm("确认删除该地址吗？")) {
                    axios({
                        url: 'address/delAddress',
                        method: 'get',
                        params: {
                            id: id
                        }
                    }).then(rs => {
                        if (rs.data == 'yes') {
                            alert('删除成功');
                            this.userAddressesList.splice(index, 1);
                        } else {
                            alert('删除失败')
                        }
                    })
                }
            },
            checkMobile(str) {//手机号验证
                var re = /^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[0-9])|(18[0,5-9]))\d{8}$/;
                if (re.test(str)) {
                    return true;
                } else {
                    return false;
                }
            },
            checkEmail(str) {//邮箱验证
                var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/
                if (re.test(str)) {
                    return true;
                } else {
                    return false;
                }
            },
            checkthisEmail(email) {
                if (this.isEmpty(email)) {
                    alert('电子邮箱不能为空');
                    return false;
                }
                if (!this.checkEmail(email)) {
                    alert('电子邮箱输入错误');
                    return false;
                }
                return true;
            },
            checkthisMobile(mobile) {
                if (this.isEmpty(mobile)) {
                    alert('手机号不能为空');
                    return false;
                }
                if (!this.checkMobile(mobile)) {
                    alert('手机号输入错误！');
                    return false;
                }
                return true;
            },
            checkthisName(name) {
                if (this.isEmpty(name)) {
                    alert('收货人不能为空！');
                    return false;
                }
                return true;
            }
        },
        watch: {
            province: function () {
                console.log('province变动')
                this.city = '0';
                this.cities = {}
                if (this.province == '0') {
                    this.$set(this.isdisabled, 1, true)
                } else {
                    this.update('00', this.province);
                    this.$set(this.isdisabled, 1, false)
                }


            },
            city: function () {
                console.log('city变动')
                this.county = '0';
                this.counties = {}
                if (this.city == '0') {
                    this.$set(this.isdisabled, 2, true);
                } else {
                    this.update('', this.city);
                    this.$set(this.isdisabled, 2, false);
                }

            },
            county: function () {
                console.log('county变动');
                this.isshow = 0;
                this.notowns = 1;
                this.town = '0';
                this.towns = {}
                if (this.county == '0') {
                    this.$set(this.isdisabled, 3, true);
                } else {
                    this.update('1', this.county);
                    this.$set(this.isdisabled, 3, false);
                }
            },


            province2: function () {
                console.log('province2变动')
                if (this.init != 0) {
                    this.city2 = '0';
                }
                this.cities2 = {}
                if (this.province2 == '0') {
                    this.$set(this.isdisabled2, 1, true)
                } else {
                    this.update2('00', this.province2);
                    this.$set(this.isdisabled2, 1, false)
                }

            },
            city2: function () {
                console.log('city2变动')
                if (this.init != 0) {
                    this.county2 = '0';
                }
                this.counties2 = {}
                if (this.city2 == '0') {
                    this.$set(this.isdisabled2, 2, true);
                } else {
                    this.update2('', this.city2);
                    this.$set(this.isdisabled2, 2, false);
                }

            },
            county2: function () {
                console.log('county变动');
                this.isshow2 = 0;
                this.notowns2 = 1;
                if (this.init != 0) {
                    this.town2 = '0';
                }

                this.towns2 = {}
                if (this.county2 == '0') {
                    this.$set(this.isdisabled2, 3, true);
                } else {
                    this.update2('1', this.county2);
                    this.$set(this.isdisabled2, 3, false);
                }
            }
        }
    };
    var Ctor = Vue.extend(vm);
    new Ctor().$mount('.m_content');
</script>

</body>


<!--[if IE 6]>
<script src="//letskillie6.googlecode.com/svn/trunk/2/zh_CN.js"></script>
<![endif]-->
</html>
